#include "SingleIntParam.h"

SingleIntParam::SingleIntParam()
:Param() {
	value = 0;
}

SingleIntParam::SingleIntParam( const char *name )
:Param( name ) { }

SingleIntParam::SingleIntParam( SingleIntParam &src )
:Param( src ) {
	this->value = src.value;
	this->ready = src.ready;
}

void SingleIntParam::read( Input &input ) {
	input >> value;
	ready = true;
}

int SingleIntParam::set( int val ) {
	this->value = val;
	ready = true;
	return value;
}

int SingleIntParam::get() {
	if (!ready) throwNotReady();
	return value;
}

/*int SingleIntParam::operator = (SingleIntParam &val) throw (NotReady) {
	if (&val != this) {
		this->value = val.value;
		this->name = val.name;
		this->ready = val.ready;
	}
}*/

int SingleIntParam::operator = (int val) throw (NotReady) {
	return set(val);
}

int SingleIntParam::operator += (int val) throw (NotReady) {
	return set(get() + val);
}

int SingleIntParam::operator -= (int val) throw (NotReady) {
	return set(get() - val);
}

int SingleIntParam::operator *= (int val) throw (NotReady) {
	return set(get() * val);
}

int SingleIntParam::operator /= (int val) throw (NotReady) {
	return set(get() / val);
}

int SingleIntParam::operator ++ () throw (NotReady) {
	return set(get() + 1);
}

int SingleIntParam::operator ++ (int) throw (NotReady) {
	return set(get() + 1);
}

int SingleIntParam::operator -- () throw (NotReady) {
	return set(get() - 1);
}

int SingleIntParam::operator -- (int) throw (NotReady) {
	return set(get() - 1);
}

SingleIntParam::operator int () throw (NotReady) {
	return get();
}
